﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Components;
using Com.Seezt.Skins;

namespace UI.ProductManagement
{
    public partial class FrmPot0a00Edit : UI.ParentForm.BaseEdit
    {
        public FrmPot0a00Edit(string action, string text, string key)
            : base(action)
        {
            InitializeComponent();

            this.Text = text;
            this.key = key;
            //回写的方法
            this.SaveCallFuntion = "Pot0a00Manager$SaveData"; //保存的方法
            if ("A" == this.Action)
            {
                IsAfterSaveCloseWin = false;
            }
            else
            {
                LoadData();
            }
            this.Size = base.MinWindow;
        }

        protected override bool Check()
        {
            if ("A" == this.Action)
            {
                System.Collections.Hashtable hs = new System.Collections.Hashtable();
                hs["brandcode"] = this.tbSummary.GetValue("brandcode");
                hs["%muser"] = UI.Lib.Context.GetAppKeyWhere();
                bool reflt = UI.Lib.Factory.CommonHelper.Entity.DataInData("Pot0a00", hs);
                if (reflt)
                {
                    MessageBox.Show("当前品牌代码已经存在！", "提示");
                    this.tbSummary.Focus("brandcode");
                    return false;
                }

                return true;
            }
            else if ("M" == this.Action)
            {
                if ("02" == Validation.ToString(this.tbSummary.GetValue("status")))
                {
                    return (MsgBox.Show(this, "提示", "状态为删除，会删除该品牌相关商品，是否继续？", MessageBoxButtons.YesNo)
                        == DialogResult.Yes);
                }
            }

            return true;
        }

        //加载修改数据
        private void LoadData()
        {
            base.LoadEditData(null, string.Format(" a.listid ='{0}' ", this.key));
        }
    }
}